//
// Basic output class to dump MC event informations
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

#include "DMLROutput.hh"
#include "TFile.h"
#include "TTree.h"

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <fstream>
#ifdef __MAKECINT__
#pragma link C++ class vector<float>+;
#endif
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......


DMLROutput::DMLROutput(string outname)
{
  file = new TFile(outname.c_str(), "RECREATE");
 
  file->SetCompressionLevel(1);

  JPMTa=new TClonesArray("PMT");
  MPMT1a=new TClonesArray("PMT");
  MPMT2a=new TClonesArray("PMT");
  MPMT3a=new TClonesArray("PMT");
  MPMT4a=new TClonesArray("PMT");
  Particlea= new TClonesArray("Particle");
  Neutrona = new TClonesArray("Particle");
  Argona   = new TClonesArray("Particle");
  Gammaa   = new TClonesArray("Particle");

  tree = new TTree("tree","DMatterdata");
  tree->Branch("EvNum",&EvNum,"EvNum/I");
  tree->Branch("nPhoton",&nPhoton,"nPhoton/I");
  tree->Branch("nElectron",&nElectron,"nElectron/I");
  tree->Branch("nJPMThits",&nJPMThits,"nJPMThits/I");
  tree->Branch("nMPMT1hits",&nMPMT1hits,"nMPMT1hits/I");
  tree->Branch("nMPMT2hits",&nMPMT2hits,"nMPMT2hits/I");
  tree->Branch("nMPMT3hits",&nMPMT3hits,"nMPMT3hits/I");
  tree->Branch("nMPMT4hits",&nMPMT4hits,"nMPMT4hits/I");

  tree->Branch("JPMTb",&JPMTa,256000,1);
  tree->Branch("MPMT1b",&MPMT1a,256000,1);
  tree->Branch("MPMT2b",&MPMT2a,256000,1);
  tree->Branch("MPMT3b",&MPMT3a,256000,1);
  tree->Branch("MPMT4b",&MPMT4a,256000,1);
  tree->Branch("Particleb",&Particlea,256000,1);
  tree->Branch("Neutronb", &Neutrona,256000,1);
  tree->Branch("Argonb",   &Argona,256000,1);
  tree->Branch("Gammab",   &Gammaa,256000,1);

  tree->Branch("EDEP",&EDEP,"EDEP/F");
  //  tree->Branch("EKIN",&EKIN);

}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

DMLROutput::~DMLROutput()
{
  tree->Write();
  file->Close();
  delete file;
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void DMLROutput::Fill()
{
  if (tree) tree->Fill();
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void DMLROutput::Cd()
{
  if (file) file->cd();
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......







